﻿var isok = false;

function loginsubmit(emai, pass, src) {

    $.post(
   "/GateService/Uklogin.aspx",
    { ema: emai, pas: pass, langid: g_langID, login: "yes" },
    function (data) {

        if (!(+data)) {
            if (g_langID == 1033) {
                alert("Email or password Error");
            } else {
                alert("用户名或密码错误");
            }
        } else {

            login_header();
            loginSuccess(src);
        }

    }
    );
    return isok;
}
function loginSuccess(src) {
    var res = verifylogin();
    var closeCallback = (src == null || typeof src == "undefined") ? null : function () { hideLogin(); };
    if (res != null && res.Result != false) {
        var model = GetMyEvent(res.ReturnObject.ID);
        if (model != null && typeof model != 'undefined') {
            $.fn.colorbox({
                href: "/" + g_siteroot + "/successmore.html",
                width: 448,
                height: 500,
                onClosed: closeCallback
            });
        }
        else {
            $.fn.colorbox({
                href: "/" + g_siteroot + "/success.html",
                width: 448,
                height: 283,
                onClosed: closeCallback
            });
        }
    }
}


function rexEmailandPassword(emial, pass) {
    if (!/^\s*([A-Za-z0-9_-]+(\.\w+)*@([\w-]+\.)+\w{2,3})\s*$/.test($.trim(emial))) {

        if (g_langID == 1033) {
            alert("Email Erro");
        }
        else {
            alert("邮箱格式错误");
        }

        return false;
    }
    else {


        if ($.trim(pass) == "") {
            if (g_Langid == 1033) {
                alert("Please Enter Your PassWord");
            }
            else {
                alert("请输入密码");
            }

        } else {
        return true;
        }

    }



}

function lg(src) {

    if (rexEmailandPassword($("#email").val(), $("#pass").val())) {
        loginsubmit($("#email").val(), $("#pass").val(), src);
       
        //alert(isok);
    }
}




function setCookie(name, value) {
    var Days = 30;
    var exp = new Date();
    exp.setTime(exp.getTime() + Days * 24 * 60 * 60 * 1000);
    document.cookie = name + "=" + escape(value) + ";expires=" + exp.toGMTString();


    var strsec = getsec(time);
    var exp = new Date();
    exp.setTime(exp.getTime() + strsec * 1);
    document.cookie = name + "=" + escape(value) + ";expires=" + exp.toGMTString();
}
function getCookie(name) {
    var arr, reg = new RegExp("(^| )" + name + "=([^;]*)(;|$)");

    if (arr = document.cookie.match(reg))

        return (arr[2]);
    else
        return null;
}